<?php
function alert_form($msg, $url){
	echo "<script LANGUAGE=\"javascript\">alert (\"$msg\");window.location.href=\"$url\";</script>";
}
function alert_ajax($msg, $url = ''){
	echo "alert (\"$msg\");";
}
function alert_json($msg, $status, $url = ''){
	$data = array();
	$data['msg'] = $msg;
	$data['url'] = $url;
	$data['status'] = $status;
	die (json_encode($data));
}
function query_select($sql){
	$db = new mysqli('localhost', 'root', '123456', 'test', 3306);
	if (mysqli_connect_errno())
	{
		echo 'MySQL连接错误: ';
		echo mysqli_connect_error();
	}
	$result = $db->query($sql);
	return $result->fetch_all(MYSQLI_ASSOC); # 键值对模式
}
function query($sql){
	$db = new mysqli('localhost', 'root', '123456', 'test', 3306);
	if (mysqli_connect_errno())
	{
		echo 'MySQL连接错误: ';
		echo mysqli_connect_error();
	}
	$result = $db->query($sql);
	return $result;
}
?>